<?php /* Smarty version 2.6.26, created on 2010-11-29 11:46:50
         compiled from admin/dictionary.html */ ?>
<?php require_once(SMARTY_CORE_DIR . 'core.load_plugins.php');
smarty_core_load_plugins(array('plugins' => array(array('modifier', 'escape', 'admin/dictionary.html', 161, false),)), $this); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml" lang="ru" xml:lang="ru"> 
    <head>
	<title>LocalCRM</title>
	<script src="js/jquery-1.4.2.min.js" type="text/javascript"></script>
	<script src="js/jquery-ui-1.8.4.custom.min.js" type="text/javascript"></script>
	<script src="js/jquery.blockUI.js" type="text/javascript"></script>
	<script src="js/jquery.contextMenu.js" type="text/javascript"></script>
	<script src="js/crm/common.js" type="text/javascript"></script>
	<link href="css/redmond/jquery-ui-1.8.4.custom.css" rel="stylesheet" type="text/css"/>
	<link href="css/jquery.contextMenu.css" rel="stylesheet" type="text/css"/>
    </head>
    <body>
	<script type="text/javascript">
	<?php echo '
	<!--
	$(document).ready
	(
	    function()
	    {
		$(\'.menu\')
		    .find(\'li\')
			.addClass(\'ui-widget\')
			.css
			({
			    \'font-size\':	\'10pt\'
			})
			.addClass(\'ui-state-default\')
			.hover
			(
			    function(){$(this).addClass(\'ui-state-highlight\');},
			    function(){$(this).removeClass(\'ui-state-highlight\');}
			);

		$(\'a#object-add\').click
		(
		    function()
		    {
			$(\'#object-new\')
			    .dialog(\'option\',\'resizable\',false)
			    .dialog(\'option\',\'title\','; ?>
'<?php echo $this->_tpl_vars['dictionaries'][$this->_tpl_vars['table']]; ?>
'<?php echo ')
			    .dialog
			    (
				\'option\',
				\'buttons\',
				{
				    \'Сохранить\':	function()
							{
							    $(\'#object-new\').find(\'form\').submit();
							}
				}
			    )
			    .dialog(\'open\');
		    }
		);

		$(\'.data-row\')
		    .css(\'cursor\',\'default\')
		    .hover
		    (
			function(){$(this).css(\'background-color\',\'#cdcdcd\');},
			function(){$(this).css(\'background-color\',\'transparent\');}
		    )
		    .contextMenu
		    (
			{ menu:	\'contextMenu-common\' },
			function(action,el,pos)
			{
			    switch(action)
			    {
				case	\'edit\':
				    $.getJSON
				    (
					\'dictionary.php\',
					{
					    do:		\'get_info\',
					    table:	\''; ?>
<?php echo $this->_tpl_vars['table']; ?>
<?php echo '\',
					    id:		$(el).children().html(),
					},
					function(json)
					{
					    if ( !json[\'object\'] ) { alert(\'Ошибка получения объекта!\'); return false; }

					    var tr = false;
					    for ( keyVar in json[\'object\'] )
					    {
						tr += \'<tr><td align="right">\'+(json[\'titles\'][keyVar]?json[\'titles\'][keyVar]:keyVar)+\'</td><td><textarea name="\'+keyVar+\'" \'+((keyVar==\'id\'||keyVar==\'options\')?\'readonly\':false)+\' style="width: 100%;">\'+json[\'object\'][keyVar]+\'</textarea></td></tr>\';
					    }

					    $(\'#object-edit\').find(\'table\').html(tr);

					    $(\'#object-edit\')
						.dialog(\'option\',\'resizable\',false)
						.dialog(\'option\',\'width\',480)
						.dialog(\'option\',\'title\','; ?>
'<?php echo $this->_tpl_vars['dictionaries'][$this->_tpl_vars['table']]; ?>
'<?php echo ')
						.dialog
						(
						    \'option\',
						    \'buttons\',
						    {
							\'Сохранить\':	function()
									{
									    $(\'#object-edit\').find(\'form\').submit();
									}
						    }
						)
						.dialog(\'open\');
					}
				    )
				    break;

				case	\'delete\':
				    if(window.confirm(\'Вы уверены?\'))
				    {
					$.getJSON
					(
					    \'dictionary.php\',
					    {
						do:	\'delete\',
						table:	\''; ?>
<?php echo $this->_tpl_vars['table']; ?>
<?php echo '\',
						id:	$(el).children().html(),
					    },
					    function(json)
					    {
						switch(json[\'code\'])
						{
						    case	200:
							window.location.reload();
							break;

						    case	403:
							alert(\'Невозможно удалить объект, т.к. в базе есть другие, зависимые от него, объекты!\');
							break;

						    default:
							alert(\'Ошибка! \'+json[\'code\']);
							break;
						}
					    }
					);
				    }
				    break;
			    }
			}
		    );
	    }
	);
	-->
	'; ?>

	</script>

	<?php if ($this->_tpl_vars['table'] != ''): ?>
	<div class="dialog" id="object-new">
	    <form method="post">
	    <input type="hidden" name="table" value="<?php echo $this->_tpl_vars['table']; ?>
"/>
	    <table>
	    <?php $_from = $this->_tpl_vars['fields']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }if (count($_from)):
    foreach ($_from as $this->_tpl_vars['field']):
?>
		<?php if ($this->_tpl_vars['field']['Field'] != 'id'): ?>
		<tr>
		    <td align="right"><?php if ($this->_tpl_vars['title'][$this->_tpl_vars['table']][$this->_tpl_vars['field']['Field']] != ''): ?><?php echo $this->_tpl_vars['title'][$this->_tpl_vars['table']][$this->_tpl_vars['field']['Field']]; ?>
<?php else: ?><?php echo $this->_tpl_vars['field']['Field']; ?>
<?php endif; ?></td>
		    <td><input type="text" name="<?php echo $this->_tpl_vars['field']['Field']; ?>
" value="<?php echo ((is_array($_tmp=$this->_tpl_vars['field']['Default'])) ? $this->_run_mod_handler('escape', true, $_tmp) : smarty_modifier_escape($_tmp)); ?>
"/></td>
		</tr>
		<?php endif; ?>
	    <?php endforeach; endif; unset($_from); ?>
	    </table>
	    </form>
	</div>

	<div class="dialog" id="object-edit">
	    <form method="post">
	    <input type="hidden" name="table" value="<?php echo $this->_tpl_vars['table']; ?>
"/>
	    <table width="100%">
	    </table>
	    </form>
	</div>

	<ul id="contextMenu-common" style="display: none;">
	    <li class="edit"><a href="#edit">Изменить</a></li>
	    <li class="delete"><a href="#delete">Удалить</a></li>
	</ul>
	<?php endif; ?>

	<table width="100%">
	    <tr>
		<td valign="top" width="20%" style="border-right: solid 2px #000000;">
		    <ul class="menu">
		    <?php $_from = $this->_tpl_vars['dictionaries']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }if (count($_from)):
    foreach ($_from as $this->_tpl_vars['key'] => $this->_tpl_vars['dictionary']):
?>
			<li <?php if ($this->_tpl_vars['table'] == $this->_tpl_vars['key']): ?>class="ui-state-active"<?php endif; ?>><a href="?table=<?php echo $this->_tpl_vars['key']; ?>
"><?php echo $this->_tpl_vars['dictionaries'][$this->_tpl_vars['key']]; ?>
</a></li>
		    <?php endforeach; endif; unset($_from); ?>
		    </ul>
		</td>
		<td valign="top">
		    <?php if ($this->_tpl_vars['table'] != ''): ?>
		    <table class="ui-widget" cellspacing="0">
			<thead class="ui-widget-header">
			<?php $_from = $this->_tpl_vars['fields']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }if (count($_from)):
    foreach ($_from as $this->_tpl_vars['field']):
?>
			    <th><?php if ($this->_tpl_vars['title'][$this->_tpl_vars['table']][$this->_tpl_vars['field']['Field']] != ''): ?><?php echo $this->_tpl_vars['title'][$this->_tpl_vars['table']][$this->_tpl_vars['field']['Field']]; ?>
<?php else: ?><?php echo $this->_tpl_vars['field']['Field']; ?>
<?php endif; ?></th>
			<?php endforeach; endif; unset($_from); ?>
			</thead>
			<tbody>
			<?php $_from = $this->_tpl_vars['items']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }if (count($_from)):
    foreach ($_from as $this->_tpl_vars['item']):
?>
			    <tr class="data-row">
			    <?php $_from = $this->_tpl_vars['fields']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }if (count($_from)):
    foreach ($_from as $this->_tpl_vars['field']):
?>
				<td><?php echo $this->_tpl_vars['item'][$this->_tpl_vars['field']['Field']]; ?>
</td>
			    <?php endforeach; endif; unset($_from); ?>
			    </tr>
			<?php endforeach; else: ?>
			    <tr><td align="center" colspan="999"><i>Объектов не найдено</i></td></tr>
			<?php endif; unset($_from); ?>
			</tbody>
		    </table>
		    <br/>
		    <a href="javascript:void(0)" id="object-add"><img src="images/icons/plus_16.png" border="0"/>&nbsp;Добавить объект</a>
		    <?php endif; ?>
		</td>
	    </tr>
	</table>

    </body>
</html>